import javax.microedition.lcdui.Graphics;

public class ItemMenu {
	
	private static final int ITEM_COLOR = 0xFFAE08;
	private static final int PADDING = 2;
	public static final int ITEM_HEIGHT = PADDING * 2 + ThemeManager.Big.pieceHeight;
	
	private int minY;
	private int maxY;
	
	private int curY;
	private int canvasWidth;
	public String text;
	public int eventCode;
	
	public ItemMenu(String text, int eventCode, int index, int numItem,
			int wCanvas, int hCanvas) {
		this.text = text;
		this.canvasWidth = wCanvas;
		this.eventCode = eventCode;
		int totalHeight = numItem * ITEM_HEIGHT;
		curY = minY = (hCanvas - totalHeight) / 2 + PADDING;
		maxY = minY + index * ITEM_HEIGHT;
	}
	
	public void paint(Graphics g, boolean isHighlight) {
		if (this.eventCode == -1) return;
		if (isHighlight) {
			g.setColor(ITEM_COLOR);
			g.fillRect(0, curY - PADDING, canvasWidth, ITEM_HEIGHT);
		}
		ThemeManager.drawStringCenter(g, text, canvasWidth, curY,
				ThemeManager.BIG_STYLE, Graphics.TOP);
		if (curY < maxY) {
			curY += (maxY - curY) / 4 + 1;
		}
	}

	public void reset() {
		curY = minY;
	}

}
